
#ifndef _LUTIL_H
#define _LUTIL_H 1

#include "radius_cdef.h"


RADIUS_BEGIN_DECL



typedef unsigned int   uint32_t;
typedef unsigned short u_short;
typedef unsigned char  uint8_t;
typedef int			   int32_t;

#define L_DBG			1
#define L_AUTH			2
#define L_INFO			3
#define L_ERR			4
#define L_PROXY			5
#define L_CONS			128

RADIUS_LUTIL_F( char* )


lutil_progname RADIUS_P((
	const char* name,
	int argc,
	char *argv[] ));

typedef struct lutil_tm {
	int tm_sec;	/* seconds 0-60 (1 leap second) */
	int tm_min;	/* minutes 0-59 */
	int tm_hour;	/* hours 0-23 */
	int tm_mday;	/* day 1-31 */
	int tm_mon;	/* month 0-11 */
	int tm_year;	/* year - 1900 */
	int tm_usec;	/* microseconds */
} lutil_tm;

typedef struct lutil_timet {
	unsigned int tt_sec;	/* seconds since 1900 */
	int tt_gsec;		/* seconds since 1900, high 7 bits */
	unsigned int tt_usec;	/* microseconds */
} lutil_timet;

RADIUS_LUTIL_F( int )
lutil_parsetime RADIUS_P((
	char *atm, struct lutil_tm * ));

RADIUS_LUTIL_F( int )
lutil_tm2time RADIUS_P((
	struct lutil_tm *, struct lutil_timet * ));

#ifdef _WIN32
RADIUS_LUTIL_F( void )
lutil_slashpath RADIUS_P(( char* path ));
#define	LUTIL_SLASHPATH(p)	lutil_slashpath(p)
#else
#define	LUTIL_SLASHPATH(p)
#endif

RADIUS_LUTIL_F( char* )
lutil_strcopy RADIUS_P(( char *dst, const char *src ));

RADIUS_LUTIL_F( char* )
lutil_strncopy RADIUS_P(( char *dst, const char *src, size_t n ));

struct tm;

/* use this macro to statically allocate buffer for lutil_gentime */
#define LDAP_LUTIL_GENTIME_BUFSIZE	22
#define lutil_gentime(s,m,t)	lutil_localtime((s),(m),(t),0)
RADIUS_LUTIL_F( size_t )
lutil_localtime RADIUS_P(( char *s, size_t smax, const struct tm *tm,
			long delta ));

#ifndef HAVE_MKSTEMP
RADIUS_LUTIL_F( int )
mkstemp RADIUS_P (( char * template ));
#endif


RADIUS_LUTIL_F( char* )
lutil_strncopy RADIUS_P(( char *dst, const char *src, size_t n ));


RADIUS_LUTIL_F( void )
radlog RADIUS_P((int lvl, const char *msg, ...));




RADIUS_END_DECL

#endif /* _LUTIL_H */
